{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from AP_class import AP\n",
    "import pandas as pd\n",
    "from sklearn.cluster import AffinityPropagation\n",
    "from sklearn.model_selection import GridSearchCV,ParameterGrid"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "****************************** output0 ******************************\n",
      "Model and parameters:  AffinityPropagation(damping=0.6, max_iter=400, random_state=42)\n",
      "Homogeneity Score         :  0.9743330321019187\n",
      "Completeness Score        :  0.5984997800286556\n",
      "V-Measure Score           :  0.7415131486196894\n",
      "Adjusted Rand Score       :  0.7461679051058437\n",
      "Adjusted Mutual Info Score:  0.7366869769868883\n",
      "Calinski Harabasz Score:    1732.7653335355792\n",
      "Silhouette Score          :  0.6762462280333278\n",
      "****************************** output1 ******************************\n",
      "Model and parameters:  AffinityPropagation(damping=0.7, max_iter=400, random_state=42)\n",
      "Homogeneity Score         :  0.9750290699749202\n",
      "Completeness Score        :  0.5698207533861975\n",
      "V-Measure Score           :  0.7192826005802374\n",
      "Adjusted Rand Score       :  0.7157195384969597\n",
      "Adjusted Mutual Info Score:  0.7141904922500673\n",
      "Calinski Harabasz Score:    1710.3374698071568\n",
      "Silhouette Score          :  0.6478158771103704\n"
     ]
    }
   ],
   "source": [
    "    df = pd.read_excel('test4.xlsx')\n",
    "\n",
    "    data = df.drop('TRUE VALUE', axis=1)\n",
    "    labels = df['TRUE VALUE']\n",
    "\n",
    "    # test unsupervised model\n",
    "    AP1=AP()\n",
    "    ap = AffinityPropagation(random_state=42)\n",
    "    ap_dict = AP1.read_para()\n",
    "    output = AP1.APGridsearch(ap, data, labels, ap_dict)\n",
    "\n",
    "    # AP test result\n",
    "    for i in range(len(output)):\n",
    "        AP1.get_marks(output[i], data=data, labels=labels, name=\"output\" + str(i))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
